﻿<ribbon:RibbonWindow x:Class="SimpleControlLibrary.NewMainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        xmlns:avalonDock="http://avalondock.codeplex.com"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ui="clr-namespace:SimpleControlLibrary.UI"
        xmlns:ctrl="clr-namespace:BaseControlLibrary;assembly=BaseControlLibrary" 
        WindowStartupLocation="CenterScreen" 
        WindowState="Maximized"
        FontSize="12"
        FontFamily="NSimSun"
        TextOptions.TextFormattingMode="Display"
        TextOptions.TextRenderingMode="ClearType"
        Icon="/logo2.ico" 
        mc:Ignorable="d" 
        Title="查询分析器" 
        x:Name="Window"
        Width="640" Height="480">

    <Window.Resources>
        <RoutedUICommand Text="打开" x:Key="OpenCommand"/>
        <RoutedUICommand Text="保存" x:Key="SaveCommand"/>
        <RoutedUICommand Text="运行" x:Key="RunCommand" />
        <RoutedUICommand Text="复制" x:Key="copyFieldName"/>
        <RoutedUICommand Text="删除数据源" x:Key="deldb"/>
        <RoutedUICommand Text="连接" x:Key="dbconnection"/>
        <RoutedUICommand Text="断开" x:Key="dbunconnection"/>
        <RoutedUICommand Text="清空" x:Key="txtClear"/>
        <RoutedUICommand Text="注释" x:Key="Comment"/>
        <RoutedUICommand Text="取消注释" x:Key="NoComment"/>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Gesture="F5" Command="{StaticResource RunCommand}"/>
        <KeyBinding Modifiers="Ctrl" Key="O" Command="{StaticResource OpenCommand}"/>
        <KeyBinding Modifiers="Ctrl" Key="S" Command="{StaticResource SaveCommand}"/>
        <KeyBinding Modifiers="Ctrl" Key="C" Command="{StaticResource copyFieldName}"/>
        <KeyBinding Modifiers="Ctrl" Key="D" Command="{StaticResource deldb}"/>
    </Window.InputBindings>
    <Window.CommandBindings>
        <CommandBinding Command="{StaticResource OpenCommand}"
                        Executed="OpenCommandBindingExecuted"/>
        <CommandBinding Command="{StaticResource RunCommand}"
                        Executed="RunCommandBindingExecuted"
                        CanExecute="RunCommandBindingCanExecute"/>
        <CommandBinding Command="{StaticResource SaveCommand}"
                        Executed="SaveCommandBindingExecuted"
                        CanExecute="SaveCommandBindingCanExecute"/>
        <CommandBinding Command="{StaticResource copyFieldName}" 
                        Executed="CopyFieldName_CommandBinding_Executed"/>
        <CommandBinding Command="{StaticResource deldb}" Executed="DelDB_CommandBinding_Executed" CanExecute="DelDB_CommandBinding_CanExecute"/>
        <CommandBinding Command="{StaticResource dbconnection}" Executed="ConnectionDB_CommandBinding_Executed" CanExecute="ConnectionDB_CommandBinding_CanExecute"/>
        <CommandBinding Command="{StaticResource dbunconnection}" Executed="UnConnectionDB_CommandBinding_Executed" CanExecute="UnConnectionDB_CommandBinding_CanExecute"/>
        <CommandBinding Command="{StaticResource txtClear}" Executed="TxtClear_CommandBinding_Executed" CanExecute="TxtClear_CommandBinding_CanExecute"/>
        <CommandBinding Command="{StaticResource Comment}" Executed="Comment_CommandBinding_Executed"/>
        <CommandBinding Command="{StaticResource NoComment}" Executed="NoComment_CommandBinding_Executed"/>

    </Window.CommandBindings>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition  />
            <RowDefinition Height="23"/>
        </Grid.RowDefinitions>

         <ribbon:Ribbon x:Name="Ribbon">
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu SmallImageSource="/QueryResource;component/Images/Tool/new-16x16.png" KeyTip="F">
                    <ribbon:RibbonApplicationMenuItem Header="新建文档"  ImageSource="/QueryResource;component/Images/Tool/new-16x16.png"  Command="{Binding ViewModel.AddDocumentCommand}" />
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>

            <ribbon:RibbonTab x:Name="HomeTab" Header="开始" GroupSizeReductionOrder="tabFind,tabCut, tabQuery, tabConnect">

                <ribbon:RibbonGroup x:Name="tabConnect" Header="连接" Margin="0" Width="Auto">
                    <ribbon:RibbonGroup.GroupSizeDefinitions>
                        <ribbon:RibbonGroupSizeDefinitionBaseCollection>
                            <ribbon:RibbonGroupSizeDefinition>
                                <ribbon:RibbonControlSizeDefinition ImageSize="Large"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                            </ribbon:RibbonGroupSizeDefinition>
                        </ribbon:RibbonGroupSizeDefinitionBaseCollection>
                    </ribbon:RibbonGroup.GroupSizeDefinitions>

                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/Tool/Add_16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/Add_32x32.png" Label="新建数据源"  Command="{Binding ViewModel.CreateDBCommand}"  />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/Tool/close-16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/close-32x32.png" Label="删除数据源"  Command="{StaticResource deldb}"  />
                    <ribbon:RibbonButton   SmallImageSource="/QueryResource;component/Images/Tree/btnConnect.png" Label="连接"  Command="{StaticResource dbconnection}"  />
                    <ribbon:RibbonButton  SmallImageSource="/QueryResource;component/Images/Tree/btnUnConnect.png" Label="断开"  Command="{StaticResource dbunconnection}"  />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="tabQuery" Header="查询" Width="Auto"  >
                    <ribbon:RibbonGroup.GroupSizeDefinitions>
                        <ribbon:RibbonGroupSizeDefinitionBaseCollection>
                            <ribbon:RibbonGroupSizeDefinition>
                                <ribbon:RibbonControlSizeDefinition ImageSize="Large"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Large"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="False" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="False" />
                            </ribbon:RibbonGroupSizeDefinition>
                        </ribbon:RibbonGroupSizeDefinitionBaseCollection>
                    </ribbon:RibbonGroup.GroupSizeDefinitions>

                    <ribbon:RibbonButton  LargeImageSource="/QueryResource;component/Images/run.png" Label="运行" KeyTip="F5" Command="{StaticResource RunCommand}"  />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/Tool/new-16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/new-32x32.png" Label="新建文档"  Command="{Binding ViewModel.AddDocumentCommand}"  />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/Tool/open-16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/open-32x32.png" Label="打开" KeyTip="Ctrl+O" Command="{StaticResource OpenCommand}"  />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/Tool/save-16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/save-32x32.png" Label="保存" KeyTip="Ctrl+S" Command="{StaticResource SaveCommand}"  />

                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="tabCut" Header="剪切板" Width="Auto"  >
                    <ribbon:RibbonGroup.GroupSizeDefinitions>

                        <ribbon:RibbonGroupSizeDefinitionBaseCollection>

                            <ribbon:RibbonGroupSizeDefinition>

                                <ribbon:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True" />

                                <ribbon:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True" />

                                <ribbon:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True" />

                                <ribbon:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True" />

                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                            </ribbon:RibbonGroupSizeDefinition>

                        </ribbon:RibbonGroupSizeDefinitionBaseCollection>

                    </ribbon:RibbonGroup.GroupSizeDefinitions>

                    <ribbon:RibbonButton  LargeImageSource="/QueryResource;component/Images/Tool/paste-32x32.png"  SmallImageSource="/QueryResource;component/Images/Tool/paste-16x16.png" Label="粘贴" KeyTip="Ctrl+V" Command="Paste"  />
                    <ribbon:RibbonButton  SmallImageSource="/QueryResource;component/Images/Tool/cut-16x16.png" Label="剪切" KeyTip="Ctrl+X" Command="Cut"  />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/Tool/Delete_16x16.png" Label="清空" Command="{StaticResource txtClear}"  />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/Tool/SelectAll_16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/SelectAll_32x32.png" Label="全选" Command="SelectAll" KeyTip="Ctrl+A" />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/IndentIncrease_16x16.png" Label="注释" Command="{StaticResource Comment}"  />
                    <ribbon:RibbonButton SmallImageSource="/QueryResource;component/Images/IndentDecrease_16x16.png" Label="取消注释" Command="{StaticResource NoComment}"  />
                    <ribbon:RibbonButton  SmallImageSource="/QueryResource;component/Images/Tool/undo-16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/undo-32x32.png" Label="撤销" KeyTip="Ctrl+Z" Command="Undo"  />
                    <ribbon:RibbonButton  SmallImageSource="/QueryResource;component/Images/Tool/undo-16x16.png" LargeImageSource="/QueryResource;component/Images/Tool/redo-32x32.png" Label="重做" KeyTip="Ctrl+Y" Command="Redo"  />

                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="tabFind" Header="查找" Width="Auto">
                    <ribbon:RibbonGroup.GroupSizeDefinitions>
                        <ribbon:RibbonGroupSizeDefinitionBaseCollection>
                            <ribbon:RibbonGroupSizeDefinition>
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                                <ribbon:RibbonControlSizeDefinition ImageSize="Small"  IsLabelVisible="True" />
                            </ribbon:RibbonGroupSizeDefinition>
                        </ribbon:RibbonGroupSizeDefinitionBaseCollection>
                    </ribbon:RibbonGroup.GroupSizeDefinitions>

                    <ribbon:RibbonButton LargeImageSource="/QueryResource;component/Images/Tool/Find_32x32.png"  SmallImageSource="/QueryResource;component/Images/Tool/Find_16x16.png"  Label="查找"  Command="Find" KeyTip="Ctrl+F" />
                    <ribbon:RibbonButton  LargeImageSource="/QueryResource;component/Images/Tool/Replace_32x32.png" SmallImageSource="/QueryResource;component/Images/Tool/Replace-16x16.png"  Label="替换"  Command="Replace" KeyTip="Ctrl+H" />

                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="InterfaceTab" Header="界面">
                <ribbon:RibbonGroup Header="Group" Width="Auto">
                    <ribbon:RibbonButton x:Name="BtnVerition" Label="原生模式" Click="BtnVerition_Click"/>
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>

            <ribbon:RibbonButton x:Name="BtnMin" SmallImageSource="/QueryResource;component/Images/Tool/Add_16x16.png" Click="Minimize_Click"/>
        </ribbon:Ribbon>

        <avalonDock:DockingManager Grid.Row="1" x:Name="dockManager" AllowMixedOrientation="True" DocumentClosing="DockManagerDocumentClosing"
                                   >
            <!--<avalonDock:DockingManager.Theme>
                <avalonDock:AeroTheme/>
            </avalonDock:DockingManager.Theme>-->
            <avalonDock:DockingManager.DocumentHeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding IconSource}" Margin="0,0,4,0"/>
                        <TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis"/>
                    </StackPanel>
                </DataTemplate>
            </avalonDock:DockingManager.DocumentHeaderTemplate>
            <avalonDock:LayoutRoot>
                <avalonDock:LayoutPanel Orientation="Horizontal">
                    <avalonDock:LayoutAnchorablePane DockWidth="200">
                        <avalonDock:LayoutAnchorable Title="数据源" CanClose="False">
                            <!--数据源-->
                            <ctrl:DBTreeViewControl x:Name="dbtreeview"/>
                        </avalonDock:LayoutAnchorable>
                    </avalonDock:LayoutAnchorablePane>

                    <avalonDock:LayoutPanel Orientation="Vertical">
                        <avalonDock:LayoutDocumentPaneGroup>
                            <avalonDock:LayoutDocumentPane x:Name="documentGroup">
                                <avalonDock:LayoutDocument Title="文档" x:Name="documentSQL" IconSource="/QueryResource;component/Images/Tool/copy-16x16.png" CanClose="False">
                                    <!--文档-->
                                    <ctrl:SQLControl x:Name="sqlcontrol" Tag="{Binding ElementName=documentSQL}"/>
                                </avalonDock:LayoutDocument>
                            </avalonDock:LayoutDocumentPane>
                        </avalonDock:LayoutDocumentPaneGroup>

                        <avalonDock:LayoutAnchorablePaneGroup DockHeight="300">
                            <avalonDock:LayoutAnchorablePane>
                                <avalonDock:LayoutAnchorable  Title="日志" x:Name="documentLog" CanClose="False">
                                    <!--日志-->

                                    <ui:LogControl x:Name="logcontrol" />
                                </avalonDock:LayoutAnchorable>
                                <avalonDock:LayoutAnchorable Title="数据" x:Name="documentDS" CanClose="False">
                                    <!--数据-->
                                    <ui:GridViewControl x:Name="gridviewcontrol"/>
                                </avalonDock:LayoutAnchorable>
                            </avalonDock:LayoutAnchorablePane>

                        </avalonDock:LayoutAnchorablePaneGroup>
                    </avalonDock:LayoutPanel>



                </avalonDock:LayoutPanel>
            </avalonDock:LayoutRoot>
        </avalonDock:DockingManager>

        <StatusBar Grid.Row="2">
            <TextBlock Name="lbFieldName" Text="字段" MinWidth="100"/>
            <TextBlock Name="lbIPname" Text="IP:" MinWidth="100"/>
            <TextBlock Name="lbDBname" Text="数据库连接:" MinWidth="100"/>
            <TextBlock Name="lbUserId" Text="当前用户:" MinWidth="100"/>
            <StatusBarItem HorizontalAlignment="Right">
                <TextBlock Name="lbUpdateInfo" Text="当前版本:" MinWidth="100" />
            </StatusBarItem>

        </StatusBar>
    </Grid>
</ribbon:RibbonWindow>
